﻿using System;

namespace AgFractal.Fractals
{
    public class Manowar : AbstractFractal
    {
        public Manowar()
        {
            ID = new Guid("43CC63C1-6E89-4b87-BE9E-533DC2E74A31");
            Name = Description = "Manowar";
            R1 = -2.5; I1 = 1.5; R2 = 2; I2 = -1.5;
        }

        protected override short Calculate(double r, double i, short MaxIteration)
        {
            short j;
            Complex z = new Complex();
            Complex z0 = new Complex();
            Complex t;
            Complex start = new Complex(r, i);
            for (j = 0; j < MaxIteration; j++)
            {
                t = z * z + z0 + start;
                z0 = z;
                z = t;
                if (z.Abs2() > 4) break;
            }
            return j;
        }
    }
}
